<?php
// +----------------------------------------------------------------------
// | layerIM + Workerman + ThinkPHP5 即时通讯
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\api\controller;

use app\api\model\Chatuser;

class Index extends Base
{

    //查询用户
    public function getUser()
    {
        $user_id = input('param.extra_user_id');
        if((int)$user_id>0){
            //群主信息
            $User =new Chatuser;
            $info=$User->where('id = ' . $user_id)->where('groupid =0')->find();
            if(!empty($info)){
                return $this->renderSuccess($info);
            }else{
                return $this->renderError();
            }
        }
        return $this->renderError();

    }

    //插入用户
    public function addUser()
    {
        $User =new Chatuser;
        $data=$this->request->param();
        $data['pwd']=md5('admin');
        $data['status']='online';
        $data['groupid']=4;
        $res=$User->save($data);

        if(!empty($res)){
            return $this->renderSuccess(['im_id'=>$res]);
        }else{
            return $this->renderSuccess();
        }

    }
    

    
    
}
